/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#if !defined(AFX_PGLMAP_H__8D63690A_E25F_4D15_B3C4_F7BFBDA15B34__INCLUDED_)
#define AFX_PGLMAP_H__8D63690A_E25F_4D15_B3C4_F7BFBDA15B34__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLObject.h>
#include <pgl/core/PGLData.h>

/*!
	\defgroup PGLMapGroup Maps, surfaces and vector fields.
	\ingroup PGLObjectGroup
*/

/*! \brief A 2D Map with regular base lattice.

\ingroup PGLMapGroup

\image html map.png "Grid description"
*/
class PGLCORE_EXT_CLASS CPGLMap : public CPGLObject  
{
PGL_DECLARE_DYNCREATE(CPGLMap);
public:

	//! \name Constructors
	//@{
	//! Default constructor
	CPGLMap();
	//! Copy contstructor
	CPGLMap(const CPGLMap& l):m_pLattice(NULL) {*this=l;};
	//! assignment constructor
	CPGLMap& operator = (const CPGLMap& l);
	//! destructor
	virtual ~CPGLMap() {	SetLattice(NULL,false);};
	//@}

	//! \name Wire frame
	//@{
	//! Show wire frame
	void ShowWireFrame( bool bShow = true)				{	m_bShowWireFrame=bShow;};
	//! return true if wireframe is showed
	bool IsWireFrameVisible()const						{	return m_bShowWireFrame;};
	//@}

	//! \name GUI
	//@{
	//! adds context menu items...
	virtual void AddContextMenuItems(CMenu* pMenu);
	//! adds the line property page to the property sheet dialog.
	virtual void AddPropertyPage(CPropertySheet *pPropSheet);
	//@}

	//! \name Virtual override
	//@{
	//! Main plot function
	virtual void PlotGfx(gfxinterface::CGfxInterface& gfx);
    //! returns the extent of the datas
    virtual void GetUnionExtent(gfxinterface::CGfxInterface& gfx, CPGLRectD& rExtent);
    ///virtual function to override in derived classes
    virtual void UpdateExtent(gfxinterface::CGfxInterface& gfx);
	//@}

	//! \name Lattice
	//@{
	//! returns a pointer to the lattice
	contour::TLattice<float>* GetLattice()				{	return m_pLattice;};
	//! returns a pointer to the lattice
	const contour::TLattice<float>* GetLattice() const	{	return m_pLattice;};
	/*! \brief sets the lattice
	\param pLattice pointer to new lattice object
	\param bDeleteLattice true if lattice is deleted by the object (default is true)
	*/
	void SetLattice( contour::TLattice<float>* pLattice, bool bDeleteLattice = true);
	//@}

	//! \name Serialization and debugging
	//@{
	/// Serialize functions
	void SerializeXML(CPGLArchive& ar);

	/// Debuggin functions
	#ifdef _DEBUG
		//! MFC Dump
	    virtual void Dump( CDumpContext& dc ) const;
		//! MFC AssertValid
	    virtual void AssertValid() const;   
	#endif
	//@}
private:
	//! \name Attributes
	//@{
	/// grid
	contour::TLattice<float>* m_pLattice;
	//! delete by the object
	bool m_bDeleteLattice;
	//! Show grid
	bool m_bShowWireFrame;
	//@}
};

PGL_DECLARE_SMARTPTR( CPGLMap );

#endif // !defined(AFX_PGLMAP_H__8D63690A_E25F_4D15_B3C4_F7BFBDA15B34__INCLUDED_)
